package com.yusys.anno.ba04;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Component ：创建对象的，等同与<bean></bean>的功能
 * 属性：value 就是对象名称，也就是bean的id值
 * value的值是唯一的
 */
@Component(value = "myStudent")
@SuppressWarnings("all")
public class Student {

    private String name;

    private Integer age;

    @Resource(name = "mySchool")
    private School school;

    public Student() {
        System.out.println("==调用无参构造对象==");
    }

    @Value(value = "张飞")
    public void setName(String name) {
        this.name = name;
    }

    @Value(value = "29")
    public void setAge(Integer age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", school=" + school +
                '}';
    }
}
